import type { Posts } from "./post";

export interface createCategory {
  name: string;
}
export interface CategoryShow extends createCategory {
  id: number;
}
export interface category extends CategoryShow {
  posts?: Array<Posts>;
  createTime: Date;
  updateTime: Date;
}
export const create = ({ name }: createCategory) => {
  //开始请求
  return useServerRequest<category>("/categories", {
    method: "POST",
    body: {
      name,
    },
  });
};

export const findAll = () => {
  return useServerRequest<CategoryShow[]>("/categories", {
    method: "GET",
  });
};
